﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Data;

namespace baihoadon
{
    class hoadonDAL
    {
        public hoadonDAL()
        {

        }
        public DataTable DocDanhSachHoaDon()
        {
            SqlConnection conn = new SqlConnection();
            conn.ConnectionString = "Data Source=(local);Initial Catalog=qlvt; User Id=sa; Password=sa";

            conn.Open();
            SqlCommand cmd = new SqlCommand("select * from hoadon Inner join hanghoa on  hoadon.mahang=hanghoa.mahang  ", conn);
            SqlDataReader dr = cmd.ExecuteReader();
            DataTable dt = new DataTable();
            dt.Load(dr);
            return dt;
        }
        public void XoaHoaDon(string sohd)
        {
            SqlConnection conn = new SqlConnection();
            conn.ConnectionString = "Data Source=(local);Initial Catalog=qlvt; User Id=sa; Password=sa";

            conn.Open();
            SqlCommand cmd = new SqlCommand("delete from hoadon  where sohd='" + sohd + "'", conn);
            cmd.ExecuteNonQuery();
        }
    }
}
